/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.edu.itschapala.ssrp.dao;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.edu.itschapala.ssrp.modelo.Personal;
import mx.edu.itschapala.ssrp.modelo.Usuario;

/**
 *
 * @author ZANTA
 */
@Stateless
public class PersonalDAO extends AbstractDAO<Personal> {
    @PersistenceContext(unitName = "SSRP-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public PersonalDAO() {
        super(Personal.class);
    }
     public List<Personal> getPorCarrera(String carerra) {
        Query q = em.createNamedQuery("Personal.findByCarrera");
        q.setParameter("carrera",carerra );
        try {
            List<Personal> pe = q.getResultList();
            return pe;
        } catch (Exception e) {
            return new ArrayList<>();
        }
}
     public Personal getPorPuesto(String puesto) {
        Query q = em.createNamedQuery("Personal.findByPuesto");
        q.setParameter("puesto", puesto);
        try {
            Personal p = (Personal) q.getSingleResult();
            return p;
        } catch (Exception e) {
             
            return new Personal();
        }
    }
     public List<Personal> getListPorPuesto(String puesto) {
        Query q = em.createNamedQuery("Personal.findByPuesto");
        q.setParameter("Puesto", puesto);
        try {
            List<Personal> p = q.getResultList();
            return p;
        } catch (Exception e) {
             
            return new ArrayList<>();
        }
    }
}